package com.commpany.jdq.core.constant;


import java.util.EnumSet;
public enum  UserAttrEnum {


    ID("id", 0),
    MOBILEPHONE("mobilephone", 10003),
    NAME("name", 10002),
    IDCARD("idCard", 10004),
    ROLEID("roleId", 0),
    GENDER("性别", 10001);
    private int id;

    private String name;

    private static EnumSet<UserAttrEnum> enumSet;

    private UserAttrEnum(String name,int id) {

        this.name = name;
        this.id = id;
    }

    public static EnumSet<UserAttrEnum> getEnumSet() {
        if (null == enumSet) {
            enumSet = EnumSet.allOf(UserAttrEnum.class);
        }
        return enumSet;
    }

    /**
     * 根据 attr_id 查找 attr 枚举
     *
     * @param attId
     * @return
     */
    public static UserAttrEnum getUserAttrEnumByAttrId(int attId) {
        EnumSet<UserAttrEnum> userAttrEnumSet = getEnumSet();
        for (UserAttrEnum attrEnum : userAttrEnumSet) {
            if (attId == attrEnum.id) {
                return attrEnum;
            }
        }
        return null;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
